package a.b.c.sample.autoConfig;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Configuration
@EnableConfigurationProperties(MyBatisProperties.class)
public class MyBatisConfig {

    private MyBatisProperties properties;

    public MyBatisConfig(MyBatisProperties properties) {
        this.properties = properties;
    }

    @PostConstruct
    public void init(){
        System.out.println("高达屹立在大地之上");
    }

    @Bean
    @ConditionalOnMissingBean
    public Appv getApp(){
        return new Appv(1);
    }

    @Bean
    @ConditionalOnMissingBean
    public Web buildWeb(){
        return new Web();
    }

    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnProperty(name = "mybatis.arg0",havingValue = "0")
    public Web2 buildWeb2(){
        return new Web2();
    }
}
